package com.avocado.base.controller;


import com.avocado.base.enums.ResourcesType;
import com.avocado.base.service.ResourcesRoleService;
import com.avocado.commons.model.http.BaseResponse;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;



@Controller
@RequestMapping("/resourcesRole/*")
public class ResourcesRoleController {
	

	private final ResourcesRoleService resourcesRoleService;

	public ResourcesRoleController(ResourcesRoleService resourcesRoleService) {
		this.resourcesRoleService = resourcesRoleService;
	}

	@PreAuthorize("hasAnyAuthority('RESOURCES_ROLE_UPDATE')")
	@RequestMapping("/update")
	//清空用户菜单缓存
	@CacheEvict(value="userMenu", allEntries=true)
    public @ResponseBody BaseResponse update(ResourcesType resourcesType, Long roleId, String resourcesIds) {


		resourcesRoleService.update(roleId, resourcesType, resourcesIds);


		return BaseResponse.builder().status(1).message("操作成功!").build();
    }
	 
	

}
